package com.smartao.base.module;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.smartao.base.Constant;
import com.smartao.base.init.InitializeServiceOrder;
import com.smartao.core.init.AbstractDataInitializeService;

@Service
public class ModuleInitializeService extends AbstractDataInitializeService{

	@Autowired
	private ModuleService moduleService;
	
	@Override
	public int getOrder() {
		return InitializeServiceOrder.INIT_ORDER_MODULE;
	}

	@Override
	public void initData() throws Exception {
		if (moduleService.findByModuleKey("MODULE_BASE") != null) {
			return;
		}
		Module m1 = new Module("基础设置", Constant.MODULE_BASE);
		moduleService.save(m1);
		
		Module m2 = new Module("人事管理", Constant.MODULE_HR);
		moduleService.save(m2);
		
		Module m3 = new Module("日常工作", Constant.MODULE_DAILY);
		moduleService.save(m3);
		
		Module m4 = new Module("知识管理", Constant.MODULE_DOC);
		moduleService.save(m4);
		
		Module m5 = new Module("会议管理", Constant.MODULE_MEETING);
		moduleService.save(m5);
	}

}
